package com.itcam.iostream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Author:Cammy.Wu
 * Date:2024-05-13
 * Description:
 */

public class ByteStreamDemo04 {
    public static void main(String[] args) throws IOException {
        // 1.创建图片文件
        File f1 = new File("E:\\IOstream\\jubao.jpg");
        // 2.目标图片
        File f2 = new File("E:\\IOstream\\jubao_.jpg");
        // 3.输入管道对到源图片
        FileInputStream fis = new FileInputStream(f1);
        // 4.输出管道对到目标图片
        FileOutputStream fos = new FileOutputStream(f2);
        // 5.开始复制
        long starTime = System.currentTimeMillis();
        int n = fis.read();
        while (n != -1) {
            fos.write(n);
            n = fis.read();
        }
        long endTime = System.currentTimeMillis();
        System.out.println(endTime - starTime + "ms");
        // 6.关闭流
        fos.close();
        fis.close();
    }
}
